﻿using AyaWo.Commen;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AyaWo.WinForm
{
    public partial class HZForm : Form
    {
        public HZForm()
        {
            InitializeComponent();
            var tty = DatHelper<int>.GetDat("Hz.dat");
                SetValue(tty);
        }

        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                DatHelper<int>.SaveDat("Hz.dat", fastJSON.JSON.Instance.ToJSON(GetValue()));
                MessageBox.Show("保存成功...");
            }
            catch
            {
                MessageBox.Show("保存失败...");
            }
        }

        public int GetValue()
        {
            if (rb_2.Checked == true) return 2;
            else if (rb_5.Checked == true) return 5;
            else if (rb_10.Checked == true) return 10;
            else if (rb_20.Checked == true) return 20;
            else if (rb_40.Checked == true) return 40;
            else return 59;
        }

        public void SetValue(int ii)
        {
            if (ii == 2) rb_2.Checked = true;
            else if (ii == 5) rb_5.Checked = true;
            else if (ii == 10) rb_10.Checked = true;
            else if (ii == 20) rb_20.Checked = true;
            else if (ii == 40) rb_40.Checked = true;
            else rb_59.Checked = true;
        }
    }
}
